package com.blast.cn.ui

import android.view.KeyEvent
import androidx.recyclerview.widget.LinearLayoutManager
import com.blast.cn.R
import com.blast.cn.adapter.ControlInfoAdapter
import com.blast.cn.bean.SettingsItem
import com.wxl.common.base.AbsActivity
import com.wxl.common.util.ObservableUtil
import kotlinx.android.synthetic.main.activity_settings_layout.*

class ControllInfoActivity : AbsActivity() {

    override fun getCreateContentViewId(): Int {
        return R.layout.activity_settings_layout
    }

    override fun onCreateViewChanged() {
        setTopTitle("设备信息")
        settingsView.layoutManager = LinearLayoutManager(this)
        SettingsItem.getDeviceInfo(object : ObservableUtil.Companion.OnNextCallback<List<SettingsItem>>(){
            override fun onNext(t: List<SettingsItem>) {
                settingsView.adapter = ControlInfoAdapter(t)
            }
        })
    }

    override fun onKeyDownEvent(keyCode: Int, event: KeyEvent?): Boolean {
        if(keyCode == KeyEvent.KEYCODE_BACK){
            finish()
        }
        return true
    }
}